Ext.define('AM.view.MiddleEmpRateView', {
		extend: 'Ext.grid.Panel',
		alias : 'widget.middleEmpRateView',
		initComponent: function(){
		Ext.apply(this,{
		store : 'MiddleEmpRateStore',
		columnLines:true,
//		selModel : Ext.create('Ext.selection.CheckboxModel'),
		selModel: {
	        injectCheckbox: 0,
	        mode: "SIMPLE"     //"SINGLE"/"SIMPLE"/"MULTI"
	       
   		 },
   		selType: "checkboxmodel",
    	dockedItems: [
//    		{
//        xtype: 'pagingtoolbar',
//        dock: 'bottom',
//        store : 'MiddleEmpRateStore',
//        displayInfo: true
//        },
        {
        	dock: 'top',
	        xtype: 'toolbar',
		    items: [{
				       xtype :'button',
				       text: '评级',
				       icon: 'Ext/restful/images/cog_edit.png',
					   handler:editMiddlePingJi
			      	},'-',' 查询日期: ', 
			      	{
			        xtype:'datefield',
			        format:'Y-m-d',                    
			        id: 'Middlerate_search',            
			        width : 150
			      },'-', {
			            xtype: 'button',
			            text: '搜索',
			            icon : 'Ext/restful/images/find.png',
			            margin: '0 0 0 5',
			            handler: function () {
			                 var searchdate1 = Ext.getCmp('Middlerate_search').getValue();
			                 var grid=this.ownerCt.ownerCt;
			                   Ext.Ajax.request({
										url : 'Rate_InserMiddlePingeji',
										success : function() {
											 grid.getStore().on('beforeload', function (store, options) {
			                                    var new_params = { serchdate:Ext.util.Format.date(searchdate1, 'Y-m')};
			                                 			   Ext.apply(store.proxy.extraParams, new_params);
			                                  				  });
			               						  grid.getStore().reload();
											},
										failure : function() {
														Ext.MessageBox.alert("提示", "查询失败！");
									    	},
									   params:{serchdate:Ext.util.Format.date(searchdate1, 'Y-m')}
									});	
			        }
			   }]
	      
        }],
//        selType:  'cellmodel',
        plugins: [
			        Ext.create('Ext.grid.plugin.CellEditing', {
			            clicksToEdit: 1
			        })],
		columns: [
			        {text: '序号',  xtype: 'rownumberer',width:50,align:'center',tdCls:'background-color: #8EE5EE;'},
			        { width:0,align:'center',dataIndex: 'id'},
			        { text: '科室',  dataIndex: 'department',  width:180,align:'center' },
			        { text: '人员',dataIndex: 'employee', width:130,align:'center' },
			        { text: '考评等级', dataIndex: 'grade', width:100,align:'center',renderer: function(value){
								 if (value === 1.3) {
										 return '<span >优秀</span>';
								}
								 if (value === 1.1) {
										 return '<span >良好</span>';
								}
								 if (value === 1.0) {
										 return '<span >合格</span>';
								}
								 if (value === 0.8) {
										 return '<span >不合格</span>';
								}
						 },
			        	field: {
					        xtype: 'combobox',
			                triggerAction: 'all',
			                queryMode: 'local', 
			                store:"PingJiStore",
			                displayField:'name',
			                valueField:'id'
			              }
			        },
			        { text: '日期',  dataIndex: 'date',  width:80,align:'center'}

			     ],
			   listeners: {    
                 render: function(grid) {    
                         grid.on("itemmouseenter", function(view,record,mode,index,e) {  
                         grid.tip = Ext.create('Ext.tip.ToolTip', { 
                         	title: '考评维度',
                         	width: 420,
                         	height: 250,
                            target: view.el,            
//                          delegate: view.itemSelector, //选择行显示
                            delegate: view.cellSelector, //选择cell显示
                            trackMouse: true, 
                            listeners: {              
                                beforeshow: function updateTipBody(tip) {  
                                		gridColums = view.getGridColumns();
  									 	column = gridColums[tip.triggerElement.cellIndex];
  									 	if(column.dataIndex === 'grade'){
  									 	myToolTipText = '<div>（一）任务维度：任务维度的考评主要针对被考核人员所取得的<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;工作成果，考核职工本职工作 <div/>' +
			                            						  
						                            	 '<div>（二）态度维度：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;' +
								                            	 '1.工作态度&nbsp;&nbsp;&nbsp; '+
								                            	 '2.劳动纪律&nbsp;&nbsp;&nbsp;'+
								                            	 '3.品质素养'+
								                          '<div/>'+
						                            	 '<div>（三）管理维度：指科室负责人及科室副主任，为完成工作所应<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;具备的协作精神、管理技能、工作作风等 <div/>' +
						                            	 '<div>（四）周边维度：考核工作（业务）相关科室的团队合作精神，<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;促进工作流程在科室间的顺利推进<div/>' +		                          
						                            	  '<div>（五）能力维度：<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
						                            	  		 '1.人际交往能力&nbsp;&nbsp;&nbsp;'+
						                            	  		 '2.影响力&nbsp;&nbsp;&nbsp;'+
						                            	  		 '3.领导能力&nbsp;&nbsp;&nbsp;'+
						                            	  		 '4.沟通能力<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;'+
						                            	  		 '5.判断和决策能力&nbsp;&nbsp;&nbsp;'+
						                            	  		 '6.计划和执行能力&nbsp;&nbsp;&nbsp;'+
						                            	  		 '7.知识学习能力'+
						                            	  '<div/>'
			                            	  tip.update(myToolTipText);
			  								 
  									 	}else {
										    return false;
										   }
                                }  
                            }  
                        });  
      
                     });    
                 }    
             } 
             						});
			   this.callParent(arguments);
  	}
					
})	   
				    					
function editMiddlePingJi(){
		var grid=this.ownerCt.ownerCt;
		var selections = grid.getSelectionModel().getSelection();
			if(selections){
					if(selections.length==0){
							Ext.MessageBox.alert("提示","请检查是否选中所有行！");
							}else{   
									var grades=[]; var ids=[];
									for(var i=0;i<selections.length;i++){
										var record = selections[i];
										grades.push(record.get("grade"));
										ids.push(record.get("id"))
									  }
										Ext.Ajax.request({
										url : 'Rate_Middlepingji',
										success : function() {
//										 Ext.getCmp('performanceGridView').getStore().on('beforeload', function (store, options) {
//                                     	  var new_params = {searchValue:Ext.util.Format.date(searchValue, 'Y-m')}
//                                    	  Ext.apply(store.proxy.extraParams, new_params);
//                                  	   });
									 		 grid.getStore().reload();	
									 		 grid.getSelectionModel().deselectAll();
										},
											failure : function() {
												Ext.MessageBox.alert("提示", "保存失败！");
											},
											params : {
												    ids:ids,
												    grades:grades
												}
									});	
							}
					}	
}

	 	
